﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using School.Entities;
using School.Common;

namespace School.Organization
{
    public static class TheClass
    {
        public static SchoolEntities db = new SchoolEntities();

        public static ORG_Class Single(long id)
        {
            var classes = from x in db.ORG_Class where x.Id == id select x;

            if (classes.Count() > 0)
                return classes.First();
            else
                return null;
        }

        public static void Add(ORG_Class c)
        {
            db.AddToORG_Class(c);
            db.SaveChanges();
        }

        public static void Update(ORG_Class c)
        {
            var g = Single(c.Id);

            g.Name = c.Name;
            g.Description = c.Description;
            g.Code = c.Code;
            g.Capacity = c.Capacity;
            g.Grade_Id = g.Grade_Id;           
            db.SaveChanges();
        }
    }
}
